package com.qidianit.mes.production.controller;

import com.qidianit.common.pojo.MESResult;
import com.qidianit.mes.pojo.Process;
import com.qidianit.mes.production.service.ProcessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author djl
 * @Time 2024/10/15 23:27
 */
@RestController
@RequestMapping("/production")
@CrossOrigin
public class ProcessController {
    @Autowired
    private ProcessService processService;
    @GetMapping("/list")
    public MESResult list(String processId,String processName,Integer processStatus,
                          @RequestParam(defaultValue = "1")int page,
                          @RequestParam(defaultValue = "10")int limit) {
        return processService.queryProcess(processId,processName,processStatus,page,limit);
    }
    @GetMapping("/listAll")
    public MESResult listAll(){
        return processService.queryAll();
    }
    @GetMapping("/count")
    public MESResult countProcess(){
        return processService.countProcess();
    }
    @RequestMapping("/add")
    public MESResult addNewProcess(@RequestBody Process process){
        return processService.addNewProcess(process);
    }
    @DeleteMapping ("/delete")
    public MESResult deleteProcess(String processId){
        System.out.println(processId);
        return processService.deleteProcess(processId);
    }
    @PostMapping("/edit")
    public MESResult editProcess(@RequestBody Process process){
        return processService.editProcess(process);
    }
    @DeleteMapping("/reDelete")
    public MESResult reDelete(String[] processIds){
        return processService.reDelete(processIds);
    }
    @GetMapping("/showByProcess")
    public MESResult showByProcess(String processId){
        return processService.showByProcess(processId);
    }
}
